package com.nip.miniproject.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.nip.miniproject.comons.Constant;
import com.nip.miniproject.datatransferobject.PersonalEntity;
import com.nip.trainnig.R;

public class RegistActivity extends Activity {

	private Button btnDone;
	private EditText edUser;
	private EditText edPassword;
	private EditText edWebsite;
	private PersonalEntity _personal;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.regist_activity);
		this.Initialize();
		if (btnDone != null) {
			btnDone.setOnClickListener(this.RegistUser);
		}

	}

	private void Initialize() {
		btnDone = (Button) findViewById(R.id.btnDone);
		edUser = (EditText) findViewById(R.id.edRUser);
		edPassword = (EditText) findViewById(R.id.edRPassworld);
		edWebsite = (EditText) findViewById(R.id.edRWebsite);
	}

	private OnClickListener RegistUser = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			Intent i = new Intent(getApplication(), InformationActivity.class);
			_personal = this.GetInformation();
			i.putExtra(Constant.SEND_CODE, _personal);
			startActivity(i);
		}
		
		/**
		 * Lấy thông tin người dùng
		 * 
		 * @param personalEntity
		 *            chứa thông tin người dùng
		 */
		private PersonalEntity GetInformation() {
			PersonalEntity personalEntity = new PersonalEntity();
			personalEntity.setUserName(edUser.getText().toString());
			personalEntity.setPassWorld(edPassword.getText().toString());
			personalEntity.setWebsite(edWebsite.getText().toString());
			return personalEntity;
		}
	};

	
}
